﻿using System;
using System.ServiceModel;
using BusinessLogicLibrary;
using entities;

namespace ServiceLibrary
{
    public class AuthenticateService : IAuthenticateService
    {
        private readonly AuthenticateModule _authenticateModule = new AuthenticateModule();

        #region IAuthenticateService Members

        public string RoleGet(string userName, string passWord)
        {
            return _authenticateModule.RoleGet(userName, passWord);
        }

        public bool ChangePassword(string userName, string passWord, string newPassWord)
        {
            try
            {
                return _authenticateModule.ChangePassword(userName, passWord, newPassWord);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }

        public Employee GetEmployee(string employeeAccount, string employeePassword)
        {
            try
            {
                return _authenticateModule.EmployeeGet(employeeAccount, employeePassword);
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }

        #endregion
    }

    [ServiceContract]
    public interface IAuthenticateService
    {
        [OperationContract]
        string RoleGet(string userName, string passWord);

        [OperationContract]
        bool ChangePassword(string userName, string passWord, string newPassWord);

        [OperationContract]
        Employee GetEmployee(string employeeAccount, string employeePassword);
    }
}